package command.empresa;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import model.Empresa;
import command.ICommand;
import dao.EmpresaDAO;

public class ListarEmpresasCommand  implements ICommand{
	public String execute(HttpServletRequest request) throws ServletException,IOException {
		EmpresaDAO dao = new EmpresaDAO();
		try {
			ArrayList<Empresa> empresas = dao.listar();
			request.setAttribute("empresas", empresas);
			return "/paginas/empresa/listar_empresas.jsp";
		} catch (SQLException e) {
			e.printStackTrace();
			return "/paginas/tela_principal.jsp";
		}
		
	}

}
